package main

import "fmt"

// 动态规划 代码简单理解难点
func main()  {
	var s string = "applelenapplecat"
	var arr =  []string{"len","cat","apple"}
	m := map[string]bool{}
	for _,v := range arr{
		m[v] = true
	}
	dp := make([]bool,len(s)+1)
	dp[0] = true
	for i :=1;i<len(s)+1;i++  {
		for j := 0;j <i;j++ {
			if dp[j] && m[s[j:i]] {
				dp[i] = true
				break
			}
		}
	}
	fmt.Println(dp[len(s)])
}
